//
//  AppDeleViewModel.m
//  MusicGetPro
//
//  Created by aReu on 2017/3/15.
//  Copyright © 2017年 aReu. All rights reserved.
//

#import "AppDeleViewModel.h"
#import "aRquestModel.h"
#import "PYSearchViewController.h"
#import "aRModel.h"

@implementation AppDeleViewModel

-(instancetype)init {
    if (self = [super init]) {
        [self test];
    }
    return self;
}

-(void)test{
    _billBoardArray = @[].mutableCopy;
    _searchArray = @[].mutableCopy;
    @weakify(self);
    self.bbSinal = [RACSignal createSignal:^RACDisposable *(id<RACSubscriber> subscriber) {
//        @strongify(self);
//        [aRquestModel requestByBillBoardWithBlock:^(NSMutableArray *arr) {
//            if (arr.count > 0) {
//                [subscriber sendNext:arr];
//            }else {
//                [subscriber sendError:nil];
//            }
//            [subscriber sendCompleted];
//        }];
        [subscriber sendNext:@[@"明年今日",@"if you"]];
        [subscriber sendCompleted];
        return [RACDisposable disposableWithBlock:^{
            NSLog(@"销毁");
        }];
    }];
}

-(void)requestData:(NSString*)str{
    [aRquestModel requesWangyYunByName:str Block:^(NSMutableArray *arr) {
        if(!arr) return;
        dispatch_async(dispatch_get_main_queue(), ^{
            NSMutableArray *searchSuggestionsM = [NSMutableArray array];
            for (int i = 0; i < arr.count; i++) {
                aRModel *model = arr[i];
                [searchSuggestionsM addObject:model.title];
            }
            self.searchArray = searchSuggestionsM;
        });
    }];
}




@end
